#include<iostream>
#include<cstring>
using namespace std;
const int maxn = 205;
int f[maxn][maxn],n,a[maxn],s[maxn],dp[maxn][maxn];

int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		a[i+n]=a[i];
	}
	n=n*2;

	for(int i=1;i<=n;i++){
		s[i]=s[i-1]+a[i];
	}
	s[n+1]=s[n]+a[1];
	
	memset(f,0x7f,sizeof f);
	memset(dp,0xc0,sizeof dp);
	for(int i=1;i<=n;i++)f[i][i]=0;
	for(int i=1;i<=n;i++)dp[i][i]=0;
	
	
	for(int i=n;i>=1;i--){
		for(int j=i+1;j<n;j++){
			for(int k=i;k<j;k++){
				f[i][j]=min(f[i][j],f[i][k]+f[k+1][j]+s[j]-s[i-1]);
				dp[i][j]=max(dp[i][j],dp[i][k]+dp[k+1][j]+s[j]-s[i-1]);
			} 
		}
	}
	
 	n = n/2;
    int ans = 0x7ffffff;
    int anns = 0;
    for(int i=1;i<=n;i++){
        ans = min(ans,f[i][i+n-1]);
        anns = max(anns,dp[i][i+n-1]);
    }
    cout<<ans<<endl;
    cout<<anns<<endl;
	
}